
<meta charset="utf-8">
<script>
    var num1 = parseInt(prompt("请您输入第一个数："));   
    var num2 = parseInt(prompt("请您输入第二个数："));
    var num3 = parseInt(prompt("请您输入运算符 1.+ 2.- 3.* 4/"));

    switch(num3){
        case 1:
            alert(num1+num2);
        break;
        case 2:
            alert(num1-num2);
        break;
        case 3:
            alert(num1*num2);
        break;
        case 4:
            if(num2==0){
                alert("除数不能为零！")
            }else{
                alert(num1/num2);
            }           
        break;
        default:
            alert("错误");
        break;
    }
</script>